<?php include '../public/header.php' ?>
<?php include '../public/header_index.php' ?>
<style>
    .laytp-container .layui-table-header {height: 70px;}
    .layui-table-fixed-l .layui-table-body{width: auto !important;}
</style>
<body class="laytp-container">
<div id="opt_nav">
</div>

<div class="layui-card" id="search-form">
    <div class="layui-card-body">
        <form class="layui-form" id="TableSearchFormId" lay-filter="TableSearchForm" onkeydown="keyTableSearch('TableSearchForm', 'datalist')">
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-md3">
                        <label class="layui-form-label">项目名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="enginname" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">项目所属单位</label>
                        <div class="layui-input-block">
                            <div id="chanid" class="xmselect_div">
                                <div class="xmselect_title">请选择</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">项目属性：</label>
                        <div class="layui-input-block">
                            <select id="business" name="business" lay-filter="business">
                                <option value="">请选择</option>
                                <option value="1">自营</option>
                                <option value="2">联营</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">年度：</label>
                        <div class="layui-input-block">
                            <select id="year" name="year" lay-filter="year">
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <div class="layui-form-item search-div">
                            <div class="layui-form-item layui-inline">
                                <button class="laytp-btn laytp-btn-md laytp-btn-primary" id="TableSearchButton" type="button"><i class="layui-icon layui-icon-search"></i>查询</button>
                                <button class="layui-btn layui-btn-primary" onclick="listTableReset()" id="TableSearchReset" type="reset" ><i class="layui-icon layui-icon-refresh"></i>重置</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<div class="layui-card" id="table-card">
    <div class="layui-card-body">
        <div class="layui-row">
            <div class="layui-col-md12" id="table_list">
                <div class="layui-card-body">
                    <table id="datalist" lay-filter="datalist"></table>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/html" id="toolbarDemo">
    <div class = "layui-btn-container">
    </div>
</script>
<script>

    //获取完整的日期
    var year=(new Date).getFullYear();
    year = parseInt(year);

    var yearStr = '';
    for (var i=year; i>=year-10; i--){
        yearStr += '<option value="'+i+'">'+i+'</option>';
    }
    $("#year").html(yearStr);


    var currButAuth, currTabData;
    layui.use(["laytp",'laypage','table','dropdown','form','soulTable'], function () {
        var laypage = layui.laypage, table = layui.table, dropdown = layui.dropdown, form = layui.form, soulTable = layui.soulTable;


        $('#TableSearchReset').click(function () {
            $('.xmselect_div>xm-select').find('.xm-label-block').css('display','none');
            $('.xmselect_div').append('<div class="xmselect_title">请选择</div>');
            searchTableFunc(form, table)
        });

        setSouTableExport('项目月度产值报表');
        var mytable = table.render({
            elem: "#datalist",id: "datalist"
            ,url: facade.url(ask_chan_yue_tong),where: {year:year}, page: true, height: 'full-140'
            ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: TabInit.toolbar, overflow: TabInit.overflow
            ,defaultToolbar: TabInit.defaultToolbar,filter: TabInit.filter
            ,request: TabInit.request,response: TabInit.response,contextmenu:get_table_contextmenu(soulTable)
            ,text: TabInit.text,totalRow: true
            ,parseData: function (res) {
                currButAuth = res.data.butauth;
                tableButShow(currButAuth);
                xmselect_dan('chanid', res.data.chanid, res.data.is_chanid, function (res) {
                    setTimeout(function () {
                        searchTableFunc(form, table);
                    },100)
                })


                render_from();
                return {
                    "code": res.code,
                    "msg": res.message,
                    "count": res.data.data.total,
                    "data": res.data.data.data
                };
            }
            , cols: [[
                {type: "checkbox", fixed: 'left',totalRowText: '合计',rowspan: 2}
                ,{type:'numbers',title:'序号',fixed:'left',rowspan: 2}
                ,{field: 'name', title: '项目名称',rowspan: 2}
                ,{field: 'chanfee', title: '总计划产值(元)',rowspan: 2,totalRow: true}
                ,{field: 'wanchan', title: '开累完成产值(元)',rowspan: 2,totalRow: true}
                ,{field: 'wanbi', title: '完成占比(%)',rowspan: 2,totalRow: true}
                ,{field: 'leichan', title: '开累审定产值(元)',rowspan: 2,totalRow: true}
                ,{field: 'year', title: '搜索年份',rowspan: 2}

                ,{field: '', title: '年度合计', align:'center',colspan: 2}
                ,{field: '', title: '一月', align:'center',colspan: 2}
                ,{field: '', title: '二月', align:'center',colspan: 2}
                ,{field: '', title: '三月', align:'center',colspan: 2}
                ,{field: '', title: '四月', align:'center',colspan: 2}
                ,{field: '', title: '五月', align:'center',colspan: 2}
                ,{field: '', title: '六月', align:'center',colspan: 2}
                ,{field: '', title: '七月', align:'center',colspan: 2}
                ,{field: '', title: '八月', align:'center',colspan: 2}
                ,{field: '', title: '九月', align:'center',colspan: 2}
                ,{field: '', title: '十月', align:'center',colspan: 2}
                ,{field: '', title: '十一月', align:'center',colspan: 2}
                ,{field: '', title: '十二月', align:'center',colspan: 2}
            ],
                [
                    {field: 'wanyear', title: '完成', align:'center',totalRow: true}
                    ,{field: 'shenyear', title: '审定', align:'center',totalRow: true}

                    ,{field: 'wan1', title: '完成', align:'center',totalRow: true}
                    ,{field: 'shen1', title: '审定', align:'center',totalRow: true}

                    ,{field: 'wan2', title: '完成', align:'center',totalRow: true}
                    ,{field: 'shen2', title: '审定', align:'center',totalRow: true}

                    ,{field: 'wan3', title: '完成', align:'center',totalRow: true}
                    ,{field: 'shen3', title: '审定', align:'center',totalRow: true}

                    ,{field: 'wan4', title: '完成', align:'center',totalRow: true}
                    ,{field: 'shen4', title: '审定', align:'center',totalRow: true}

                    ,{field: 'wan5', title: '完成', align:'center',totalRow: true}
                    ,{field: 'shen5', title: '审定', align:'center',totalRow: true}

                    ,{field: 'wan6', title: '完成', align:'center',totalRow: true}
                    ,{field: 'shen6', title: '审定', align:'center',totalRow: true}

                    ,{field: 'wan7', title: '完成', align:'center',totalRow: true}
                    ,{field: 'shen7', title: '审定', align:'center',totalRow: true}

                    ,{field: 'wan8', title: '完成', align:'center',totalRow: true}
                    ,{field: 'shen8', title: '审定', align:'center',totalRow: true}

                    ,{field: 'wan9', title: '完成', align:'center',totalRow: true}
                    ,{field: 'shen9', title: '审定', align:'center',totalRow: true}

                    ,{field: 'wan10', title: '完成', align:'center',totalRow: true}
                    ,{field: 'shen10', title: '审定', align:'center',totalRow: true}

                    ,{field: 'wan11', title: '完成', align:'center',totalRow: true}
                    ,{field: 'shen11', title: '审定', align:'center',totalRow: true}

                    ,{field: 'wan12', title: '完成', align:'center',totalRow: true}
                    ,{field: 'shen12', title: '审定', align:'center',totalRow: true}


                ]
            ]
            , done: function (res) {
                soulTable.render(this);
                currTabData = res.data;
                $.each(currTabData, function(index,item){
                    var chk = $('tr[data-index=' + item.LAY_TABLE_INDEX + '] .tab-list-authbut');
                    for (var key in currButAuth) {
                        if(currButAuth[key].pagetype === 0 || currButAuth[key].pagetype === 1){
                            chk.append(' <a ' +
                                'href="javascript:;" ' +
                                'class="bar_opt layui-hide" ' +
                                'lay-event="search" ' +
                                'data-butname="'+currButAuth[key].butname+'" ' +
                                'data-title="'+currButAuth[key].title+'" ' +
                                'onclick="auth_but_func_'+currButAuth[key].butname+'(\''+currButAuth[key].title+'\', '+index+')"' +
                                '>'+currButAuth[key].title+'' +
                                '</a>');
                        }
                    }
                });
                show_tab_but(currTabData);
            }
        });


        listTableSearch(form, table);
    });





</script>
</body>
</html>
